program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n, i, min, max : integer;
  mass: array of integer;
  fin, fout: textFile;

begin
  assignFile (fin, 'input.txt');
  reset (fin);
  read (fin, n);
  setlength (mass, n);
  for i:= 0 to n-1 do
    read (fin, mass[i]);
  closeFile (fin);
  min:= mass[0];
  max:= mass[0];
  for i:= 0 to n-1 do
  begin
    if (min>mass[i]) then
      min:= mass[i];
    if (max<mass[i]) then
      max:= mass[i];
  end;
  assignFile (fout, 'output.txt');
  rewrite (fout);
  write (fout, max+min);
  closeFile (fout);
end.
 